package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.systemdept.SystemDeptBO;
import com.micro.modual.model.dto.systemdept.SystemDeptDetailDTO;
import com.micro.modual.model.dto.systemdept.SystemDeptListDTO;
import com.micro.modual.model.tree.SystemDeptTreeDTO;
import com.micro.modual.service.SystemDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <h1>系统部门表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:46
 */
@Api(value = "部门管理",tags = "部门管理")
@RestController
@RequestMapping(value = "systemDept")
public class SystemDeptController {

    @Autowired
    private SystemDeptService systemDeptService;

    /**
     * <h2>查找系统部门表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<SystemDeptListDTO> {@link SystemDeptListDTO}s  系统部门表 列表返回对象
     */
    @ApiOperation(value = "查询系统部门表列表" ,notes = "查询系统部门表列表")
    @GetMapping(value = "/findSystemDeptList")
    public RespJsonData<List<SystemDeptTreeDTO>> findSystemDeptList(@RequestParam  Map<String,Object> params){
        return systemDeptService.findSystemDeptList(params);
    }

    /**
     * <h2>根据主键编号查看系统部门表详情</h2>
     * @param id  系统部门表 主键编号
     * @return {@link SystemDeptDetailDTO}  系统部门表 详情
     */
    @ApiOperation(value = "查询系统部门表详情",notes = "根据主键编号，查询系统部门表详情")
    @GetMapping(value = "/findSystemDeptDetail/{id}")
    public RespJsonData<SystemDeptDetailDTO> findSystemDeptDetail(@PathVariable("id") Long id){
        return systemDeptService.findDetail(id,SystemDeptDetailDTO.class);
    }

    /**
     * <h2>新增系统部门表详情</h2>
     * @param systemDeptBO {@link SystemDeptBO} 系统部门表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增系统部门表",notes = "新增系统部门表")
    @PostMapping(value = "/addSystemDept")
    public RespJson addSystemDept(@RequestBody SystemDeptBO systemDeptBO){
        return systemDeptService.addSystemDept(systemDeptBO);
    }

    /**
     * <h2>修改系统部门表详情</h2>
     * @param systemDeptBO  {@link SystemDeptBO} 系统部门表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改系统部门表",notes = "修改系统部门表")
    @PostMapping(value = "/editSystemDept")
    public RespJson editSystemDept(@RequestBody SystemDeptBO systemDeptBO){
        return systemDeptService.editSystemDept(systemDeptBO);
    }

    /**
     * <h2>根据主键编号删除系统部门表信息</h2>
     * @param id  系统部门表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除系统部门表",notes = "根据地址ID，删除系统部门表")
    @PostMapping(value = "/deleteSystemDept/{id}")
    public RespJson deleteSystemDept(@PathVariable("id") Long id){
        return systemDeptService.deleteSystemDept(id);
    }

    /**
     * <h2>查找部门树</h2>
     * @return
     */
    @GetMapping(value = "/findSystemDeptTree")
    public RespJsonData<List<SystemDeptTreeDTO>> findSystemDeptTree(){
        return systemDeptService.findSystemDeptTree();
    }
}

